﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace FazaDemo.PL.Wpf
{
    class VisualElemBuilder
    {

        private readonly Grid _parentGrid;

        public VisualElemBuilder(Grid parentGrid)
        {
            _parentGrid = parentGrid;
        }

        public int RowIndex { get; set; }

        public void Create<T>(string name, int colIndex)
        {
            CreateWork<T>(new ElemBuildWorker(name), colIndex);
        }

        public void CreateWithContent<T>(string content, int colIndex)
        {
            CreateWork<T>(new ContentBuildWorker(content), colIndex);
        }

        public void CreateWithClickContent<T>(string content, string name, RoutedEventHandler clickHandler, int colIndex)
        {
            CreateWork<T>(new ContentEventBuildWorker(content, name, clickHandler), colIndex);
        }

        public void CreateChecked<T>(bool isChecked, int colIndex)
        {
            CreateWork<T>(new CheckedBuildWorker(isChecked), colIndex);
        }

        private void CreateWork<T>(VisualBuildWorker worker, int colIndex)
        {
            worker.ParentGrid = _parentGrid;
            worker.RowIndex = RowIndex;
            worker.Build<T>(colIndex);
        }

    }
}
